using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;

namespace Atomic.Structures
{
	[Serializable]
	public class CompositionMapping<T>
	{
		public CompositionMapping(Composition composition, T value)
		{
			Composition = composition;
			Value = value;
		}

		public Composition Composition
		{
			get;
			private set;
		}

		public T Value
		{
			get;
			private set;
		}
	}

	[Serializable]
	[DebuggerDisplay("{DebuggerDisplay}")]
	public class CompositionMapping : CompositionMapping<double>
	{
		public CompositionMapping(Composition composition, double value)
			: base(composition, value)
		{
		}

		private string DebuggerDisplay
		{
			get
			{
				return string.Format(CultureInfo.InvariantCulture, "({0}) = {1:f4}", string.Join(", ", Composition.Constituents.Select(c => string.Format(CultureInfo.InvariantCulture, "{0} = {1:f4}", c.Atom.Symbol, c.Count))), Value);
			}
		}
	}
}
